﻿//////////////////////////////////////////////////////////////////////////
// route module
// author   : zhangpeng
// date     : 2012-2-6
//////////////////////////////////////////////////////////////////////////
function route(handle, pathName, res, req) {
    console.log("about to route a reqest for" + pathName);
    if (typeof handle[pathName] === "function") {
        handle[pathName](res, req);
    } else {
        console.log("no request handler for " + pathName);
        res.writeHead(404, { "Content-Type": "text/plain" });
        res.write("404 Not found");
        res.end();
    }
}
exports.route = route;